<?php
use yii\helpers\Html;
use \backend\controllers\DtActionFilter;
$project_id = Yii::$app->request->get("project_id");

if (!empty($project_id)){
    $isView = DtActionFilter::checkProject('project_edit',$project_id);
}else{
    $isView=true;
    return '无用户id';
}
?>
<div class="container containerShadow">
    <div class="row ">
        <div class="topimg">
            <div class="left pull-left">
                <span>非抵押物情况</span>
            </div>
            <div class="pull-right">
                <a href="javascript:;">
                    <?php
                    if ($isView){
                        echo Html::img("/image/projectDetails/edit.png",["id"=>"feiDiYaImg","data-val"=>3]);
                    }
                    ?>
                </a>
            </div>
        </div>
        <form action="" class="feidiyaW">
            <table class='tableRaius' border="0" cellspacing="0" cellpadding="0" style="border-collapse:separate;border-spacing: 0;border: 1px solid #E2E2E2;"">
                <tr>
                    <td>查封情况</td>
                    <td colspan="3">
                    	<pre><?= !empty($nonMortgage['mortgage_other_seal_state'])?$nonMortgage['mortgage_other_seal_state']:''?></pre>
                    </td>
                </tr>
                <tr>
                    <td>查封顺序</td>
                    <td colspan="3" style="padding: 10px; color: #333;">
                    	<?= !empty($nonMortgage['mortgage_other_seal_order'])?$nonMortgage['mortgage_other_seal_order']:''?>
                    </td>
                </tr>
                <tr>
                    <td>回收（保守）</td>
                    <td>
                    	<pre><?= !empty($nonMortgage['bought_reservation'])?$nonMortgage['bought_reservation']:''?></pre>
                    </td>
                    <td>回收（乐观）</td>
                    <td>
                    	<pre><?= !empty($nonMortgage['bought_radical'])?$nonMortgage['bought_radical']:''?></pre>
                    </td>
                </tr>
                <tr>
                    <td>回收亮点分析</td>
                    <td colspan="3">
                    	<pre><?= !empty($nonMortgage['bought_analysis'])?$nonMortgage['bought_analysis']:''?></pre>
                        <!--<input type="text" readonly="readonly" name=""  title="回收亮点分析" value="<?= !empty($nonMortgage['bought_analysis'])?$nonMortgage['bought_analysis']:''?>" />-->
                    </td>
                </tr>
            </table>

        </form>
        <form action="" style="display: none;" class="feidiyaEdit borderColor">
            <table class='tableRaius editTable' border="0" cellspacing="0" cellpadding="0" style="border-collapse:separate;border-spacing: 0;">
                <tr>
                    <td>查封情况</td>
                    <td colspan="3">
                        <textarea name="" rows="" class="textarea-edit" cols="" id="mortgage_other_seal_state"><?= !empty($nonMortgage['mortgage_other_seal_state'])?$nonMortgage['mortgage_other_seal_state']:''?></textarea>
                    </td>
                </tr>
                <tr>
                    <td>查封顺序</td>
                    <td colspan="3">
                        <textarea name="" rows="" cols="" class="textarea-edit" id="mortgage_other_seal_order"><?= !empty($nonMortgage['mortgage_other_seal_order'])?$nonMortgage['mortgage_other_seal_order']:''?></textarea>
                    </td>
                </tr>
                <tr>
                    <td>回收（保守）</td>
                    <td>
                        <input type="text" name="" id="bought_reservation" value="<?= !empty($nonMortgage['bought_reservation'])?$nonMortgage['bought_reservation']:''?>" />
                    </td>
                    <td class="text-center">回收（乐观）</td>
                    <td>
                        <input type="text" name="" id="bought_radical" value="<?= !empty($nonMortgage['bought_radical'])?$nonMortgage['bought_radical']:''?>" />
                    </td>
                </tr>
                <tr>
                    <td>回收亮点分析</td>
                    <td colspan="3">
                        <textarea name="" rows="" cols="" class="textarea-edit" id="bought_analysis"><?= !empty($nonMortgage['bought_analysis'])?$nonMortgage['bought_analysis']:''?></textarea>
                    </td>
                </tr>
            </table>
            <div class="cancelInConfirm clearfix">
                <input id="ajaxFDY" class="cancelInConfirmActive" type="button" value="保存" />
                <input id='cancelFDY' type="button" value="取消" />
            </div>
        </form>
    </div>
</div>

<!-- textarea 高度设置对比div -->

<div style="max-height: 1px; overflow: hidden;">
	
	<div id="d1" style="visibility:hidden;min-height: 80px;"></div>

</div>
<script>
    $(function () {
    	
		// textarea 高度展示问题
	    $(".textarea-edit").keyup(function(){
	         
	      var val = $(this).val();
	      $("#d1").html("<pre>" +val+" "+"</pre>");
	      var h = $("#d1").height() ;
	      $(this).height(h);
	    });
        var bought_analysis    = ''; //项目名称
        var bought_radical    = ''; //项目编号
        var bought_reservation = ''; //项目类型
        var mortgage_other_seal_order = '';   //省份
        var mortgage_other_seal_state = '';
        $('#ajaxFDY').click(function(){
            bought_analysis = $("#bought_analysis").val();
            bought_radical = $("#bought_radical").val();
            bought_reservation = $("#bought_reservation").val();
            mortgage_other_seal_order = $("#mortgage_other_seal_order").val();
            mortgage_other_seal_state = $("#mortgage_other_seal_state").val();
            //--------------------------项目名称/项目编号/项目类型/省份------end-------------
            var data={
                'bought_analysis':bought_analysis,
                'bought_radical':bought_radical,
                'bought_reservation':bought_reservation,
                'mortgage_other_seal_order':mortgage_other_seal_order,
                'mortgage_other_seal_state':mortgage_other_seal_state,
                'project_id':project_id,
                'package_id':package_id,
            };
            $.post('/project/ajax-save-non-mortgage-project',{'project_id':project_id,'data':data},function (res) {
                if (res){
                    layer.msg("更新成功");
                    baseW();
                }else{
                    layer.msg("更新失败");
                }
            })
            //--------------------------post数据---end----------------
        })
        //-----取消保存按钮
        $("#cancelFDY").click(function () {
            $.post('/project/ajax-un-lock',{'postion':21,'project_id':project_id},function (res) {
                var JSONData = JSON.parse(res)
                if (JSONData.code == 200){
                    layer.msg(JSONData.message);
                }else{
                    layer.msg(JSONData.message);
                }
            });
            $(".feidiyaEdit").hide();
            $(".feidiyaW").show();
        })
        //-----------------渲染无编辑页面--------------------
        function baseW() {
            $.get('/project/get-mortgage-view',{'project_id':project_id,'postion':3},function (res) {
                $(".feiDiyaDom").children().remove();
                $(".feiDiyaDom").html(res);
            })
        }
    })
</script>



